<?php
/*
 * @Date: 2021-01-30 22:27:55
 * @名称: 
 * @版本: 0.01
 * @作者: 初雪桜
 * @邮箱: 202184199@qq.com
 * @最后编辑: 初雪桜
 * @LastEditTime: 2021-03-01 20:25:57
 * @FilePath: /Site/app/useradmin/controller/Comics/User/UserInheritedUser.php
 */

namespace app\useradmin\controller\Comics\User;

use app\BaseController;
use app\useradmin\controller\DataBaseController\AuthorAndChineseTeam;
use app\useradmin\controller\DataBaseController\BookList;
use app\useradmin\controller\DataBaseController\ComicsAddInvitationAact;
use app\useradmin\controller\DataBaseController\LogController;
use Ramsey\Uuid\Uuid;
use think\facade\Db;

class UserInheritedUser extends BaseController
{
    /**
     * @方法名: 允许用户继承
     * @作者: 初雪桜
     * @信息: 用户继承同意
     * @return Json
     */
    public function InheritedUsersAreAllowedToJoin()
    {

        $token = cookie("Authorization");;
        $userTokenVerificationParse = ParseUserToken($token, true);
        if ($userTokenVerificationParse['code'] != 200) {
            return json($userTokenVerificationParse);
        }
        $user_info = $userTokenVerificationParse["data"]["user_info"];


        $postData['initListType'] = input('post.initListType'); //修改的用户类型
        $postData['initListUser_id'] = input('post.initListUser_id'); //修改的用户id
        $postData['newListUser_id'] = input('post.newListUser_id'); //修改的用户id
        $postData['toKen'] = input('post.toKen'); //toKen我自己的
        $postData['bookId'] =  input('post.bookId'); //书籍id
        $postData['time'] = input('post.time'); //时间戳
        $postData['verificationBookId'] = input('post.verificationBookId'); //sha256的书籍id


        $hashHmac_toKen = hash_hmac("sha256", $token  .  $postData['bookId'] . $postData['time'], config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //加密后 加密id
        $hashHmac_bookId = hash_hmac("sha256",   $postData['bookId'] . $postData['time'], config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //加密后 加密id
        if ($hashHmac_toKen == $postData['toKen']) { //判断加密的token是不是通过

            if ($hashHmac_bookId == $postData['verificationBookId']) { //验证书籍id
                if (count($postData['newListUser_id']) != 1) {
                    return errorJsonReturn('Array subscript exceeded', '数组下标超出 是不是有东西只能单选却多选了呐！'); //这里是 要操作的用户 只能有一个却输入了两个或两个以上
                } else {
                    $postData['DecodeListUser_Info'] = authcode($postData['newListUser_id'][0], 'DECODE', config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //!解密传入的用户信息
                    if ($postData['DecodeListUser_Info'] != '') {
                        $postData['jsonDecodeUserInfo'] = json_decode(base64_decode($postData['DecodeListUser_Info']), true); //!base64解码要操作的用户信息
                        if ($postData['jsonDecodeUserInfo'] != null) {
                            $tempHashHmac = hash_hmac('sha256', $postData['jsonDecodeUserInfo']['user_id'] . $postData['bookId'] . $postData['jsonDecodeUserInfo']['time'], config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //加密后 加密id
                            if ($tempHashHmac == $postData['jsonDecodeUserInfo']['hash_hmac_user_id']) { //判断是不是 加密的信息和解析出来的用户信息一致
                                if ($postData['initListType'][0] != null) {
                                    //可以继续验证//!这里验证完成了 jsonDecodeUserInfo 新用户解析 jsonDecodeinitListUserInfo这是原用户
                                    $postData['initListType'] = $postData['initListType'][0];
                                } else {
                                    return errorJsonReturn('Permissions Request Error');
                                }
                            } else {
                                return errorJsonReturn('Failed to resolve user', '解析用户信息失败');
                            }
                        } else {
                            return errorJsonReturn('parse user info fail', '解析用户信息失败');
                        }
                    } else {
                        /*
                         * 已通过用户token的验证  
                         * 但是解析传入的用户数据时候出现问题 无法解密
                         */
                        return errorJsonReturn('Failed to resolve user', '请尝试重新请求或刷新');
                    };
                }
            } else {
                return errorJsonReturn('Validation failed', 'SeverError'); //到这里就是验证错误 验证书籍错误
            }
            $postData['DecodeinitListUserInfo'] = authcode($postData['initListUser_id'], 'DECODE', config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //!解密传入的用户信息

            $meIsAuthor = Db::table('author_and_chinese_team') //!判断我是不是作者
                ->where([
                    "book_id" => $postData['bookId'],
                    "user_id" => $user_info["_id"],
                    "author_or_chinese_team" => 0,
                    "state" => 0,
                ])
                ->count();
            if (!$meIsAuthor) { //如果登录的用户是管理员的在执行
                return errorJsonReturn('User permission error', '请刷新网页再试' . __LINE__); //!当用户已处于其他状态时候 
            }

            if ($postData['DecodeinitListUserInfo'] != '' && $postData['DecodeListUser_Info'] != '') {
                $postData['jsonDecodeinitListUserInfo'] = json_decode(base64_decode($postData['DecodeinitListUserInfo']), true); //!base64解码要操作的用户信息
                if ($postData['jsonDecodeinitListUserInfo'] != null) {
                    $tempHashHmac = hash_hmac('sha256', $postData['jsonDecodeinitListUserInfo']['user_id'] . $postData['bookId'] . $postData['time'], config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //加密后 加密id
                    if ($tempHashHmac == $postData['jsonDecodeinitListUserInfo']['hash_hmac_user_id']) { //判断是不是 加密的信息和解析出来的用户信息一致
                        //可以继续验证//!这里验证完成了 jsonDecodeinitListUserInfo 原用户解析

                    } else {
                        return errorJsonReturn('Failed to resolve user', '解析用户信息失败-新');
                    }
                } else {
                    return errorJsonReturn('parse user info fail', '解析用户信息失败-新');
                }
                // ! 移交用户
                if ($postData['jsonDecodeinitListUserInfo']['user_id'] != $postData['jsonDecodeUserInfo']['user_id']) {
                    $selectAuthorAndChineseTeam =  Db::table('author_and_chinese_team')
                        ->where([
                            "book_id" => $postData['bookId'],
                            "user_id" => $postData['jsonDecodeUserInfo']["user_id"],
                        ])
                        ->find();

                    if ($selectAuthorAndChineseTeam) { //!添加的用户已在作者或著作列表里
                        return errorJsonReturn('Change failed this user is already in the group', '更改失败该用户已在群组中');
                    }

                    //!确实是移交用户 执行
                }
                //!不移交用户权限
                try {
                    $selectAuthorAndChineseTeam =  Db::table('author_and_chinese_team')
                        ->where([
                            "book_id" => $postData['bookId'],
                            "user_id" => $postData['jsonDecodeinitListUserInfo']["user_id"],
                            "exp_state" =>   9,
                            "state" => 1,
                        ])
                        ->update([
                            "author_or_chinese_team" => $postData['initListType'],
                            "exp_state" => 9,
                            "state" => 0,
                        ]); //设置自己为可用
                    if ($selectAuthorAndChineseTeam) {
                        unset($selectAuthorAndChineseTeam);
                        $selectAuthorAndChineseTeam =  Db::table("author_and_chinese_team") //查询自己的id
                            ->where([
                                "book_id" => $postData['bookId'],
                                "user_id" => $postData['jsonDecodeinitListUserInfo']["user_id"],
                                "author_or_chinese_team" => $postData['initListType'],
                                "exp_state" => 9,
                                "state" => 0,
                            ])
                            ->field([
                                "_id"
                            ])
                            ->find();
                        if ($selectAuthorAndChineseTeam) {
                            $LogController = new LogController($this->app);
                            $LogController->update_aact_log(
                                $postData['bookId'],
                                $selectAuthorAndChineseTeam['_id'],
                                1,
                                $user_info["_id"],
                            );
                        } else {
                            return errorJsonReturn('Failed to activate user user already in another state', '请刷新网页再试' . __LINE__); //!当用户已处于其他状态时候 
                        }
                    } else {
                        return errorJsonReturn('Failed to activate user user already in another state', '请刷新网页再试' . __LINE__); //!当用户已处于其他状态时候 
                    }
                } catch (\Throwable $th) {
                    //throw $th;
                }
            } else {
                return errorJsonReturn('Failed to resolve user', '请尝试重新请求或刷新');
            };
        } else {
            return errorJsonReturn('Validation failed', 'SeverError'); //到这里就是验证错误
        }
    }
    public function RefuseToInherit()
    {
        $token = cookie("Authorization");;
        $userTokenVerificationParse = ParseUserToken($token, true);
        if ($userTokenVerificationParse['code'] != 200) {
            return json($userTokenVerificationParse);
        }
        $user_info = $userTokenVerificationParse["data"]["user_info"];


        $postData['initListType'] = input('post.initListType'); //修改的用户类型
        $postData['initListUser_id'] = input('post.initListUser_id'); //修改的用户id
        $postData['toKen'] = input('post.toKen'); //toKen我自己的
        $postData['bookId'] =  input('post.bookId'); //书籍id
        $postData['time'] = input('post.time'); //时间戳
        $postData['verificationBookId'] = input('post.verificationBookId'); //sha256的书籍id


        $hashHmac_toKen = hash_hmac("sha256", $token  .  $postData['bookId'] . $postData['time'], config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //加密后 加密id
        $hashHmac_bookId = hash_hmac("sha256",   $postData['bookId'] . $postData['time'], config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //加密后 加密id
        if ($hashHmac_toKen == $postData['toKen']) { //判断加密的token是不是通过

            if ($hashHmac_bookId != $postData['verificationBookId']) { //验证书籍id
                return errorJsonReturn('Validation failed', 'SeverError'); //到这里就是验证错误 验证书籍错误
            }
            $postData['DecodeinitListUserInfo'] = authcode($postData['initListUser_id'], 'DECODE', config("useradminConfig.useradmin_Edit_EditComicsInfo_sha256Encryption")); //!解密传入的用户信息
            $postData['jsonDecodeinitListUserInfo'] = json_decode(base64_decode($postData['DecodeinitListUserInfo']), true); //!base64解码要操作的用户信息
            $meIsAuthor = Db::table('author_and_chinese_team') //!判断我是不是用户
                ->where([
                    "book_id" => $postData['bookId'],
                    "user_id" => $user_info["_id"],
                    "author_or_chinese_team" => 0,
                    "state" => 0,
                ])
                ->count();
            if (!$meIsAuthor) { //如果登录的用户是管理员的在执行
                return errorJsonReturn('User permission error', '请刷新网页再试' . __LINE__); //!当用户已处于其他状态时候 
            }
            $selectAuthorAndChineseTeam =  Db::table("author_and_chinese_team") //查询自己的id
                ->where([
                    "book_id" => $postData['bookId'],
                    "user_id" => $postData['jsonDecodeinitListUserInfo']["user_id"],
                    "author_or_chinese_team" => $postData['initListType'],
                    "exp_state" => 9,
                    "state" => 1,
                ])
                ->field([
                    "_id"
                ])
                ->find();
            //@v设置被继承者为拒绝状态
            Db::table('author_and_chinese_team')
                ->where([
                    "book_id" => $postData['bookId'],
                    "user_id" => $postData['jsonDecodeinitListUserInfo']['user_id'],
                    "exp_state" =>   9,
                    "state" => 1,
                ])
                ->update([
                    "author_or_chinese_team" => $postData['initListType'],
                    "exp_state" => 12,
                    "state" => 1,
                    "is_deleted" => 1,
                ]);

            $LogController = new LogController($this->app);
            $LogController->update_aact_log(
                $postData['bookId'],
                $selectAuthorAndChineseTeam['_id'],
                2,
                $user_info["_id"],
            );
        } else {
            return errorJsonReturn('Validation failed', 'SeverError'); //到这里就是验证错误
        }
    }
    public function InviteToJoin($user_info, $postData)
    {
        if ($postData['code'] == 200) {
            $postData = $postData['data'];

            //查询我的权限 有没有审核 权限
            $AuthorAndChineseTeam = new AuthorAndChineseTeam($this->app);
            $MePermission_edit_add_user = $AuthorAndChineseTeam->Select( //判断我对这个文章有没有增加用户的权限
                $user_info["_id"],
                $postData['bookId'],
                ['edit_add_user', 'state', 'author_or_chinese_team', "edit_edit_user"],
            );
            if ($MePermission_edit_add_user['code'] == 200) {
                $MePermission_edit_add_user = $MePermission_edit_add_user['data'];
            } else {
                return $MePermission_edit_add_user;
            }
            $AuthorAndChineseTeam = new AuthorAndChineseTeam($this->app);
            $youState = $AuthorAndChineseTeam->Select( //查询他的当前状态
                $postData['jsonDecodeinitListUserInfo']['user_id'],
                $postData['bookId'],
                ['allow_invitation', 'state', 'is_deleted', "_id"],
            );
            if ($youState['code'] == 200) {
                $youState = $youState['data'];
            } else {
                return $youState;
            }
            $BookList = new BookList($this->app);
            $bookInfo = $BookList->find($postData['bookId'], ["title", "_id"])["data"]; //@i 查询 标题和id
            $user_info['head_images'] = session("HeadImages");

            if ($MePermission_edit_add_user['author_or_chinese_team'] == 0 && $MePermission_edit_add_user['state'] == 0) { //如果我是作者 并且状态正常
                if ($youState['state'] == 1 && $youState['is_deleted'] == 1 && $youState['allow_invitation'] == 0 && $youState['state'] == 1) {
                    //查询对方是否 已经邀请过了
                    $ComicsAddInvitationAact = new ComicsAddInvitationAact($this->app);
                    $youIsExistence = $ComicsAddInvitationAact->find(
                        $postData['jsonDecodeinitListUserInfo']['user_id'],
                        $postData['bookId'],
                    )['data'];
                    if ($youIsExistence) { //查询是否邀请过
                        $timeOut = strtotime($youIsExistence['add_time']) + config("useradminConfig.ValidTimeOfActivationFile"); //之前申请验证码的过期时间
                        if ($timeOut > time() && $youIsExistence['certification_time'] == null) {
                            return json_decode(errorJsonReturn("AuthorAndChineseTeam-InviteToJoin-10004", "对方邀请邮件尚未过期 请在" . date("Y-m-d H:i:s", $timeOut) . "后在尝试邀请")->getContent(), true);
                        }
                        return $this->InsertAndSend($postData['jsonDecodeinitListUserInfo'],  $bookInfo, $user_info, $youState["_id"]);
                    }
                    return $this->InsertAndSend($postData['jsonDecodeinitListUserInfo'], $bookInfo, $user_info, $youState["_id"]);
                } else {
                    return json_decode(errorJsonReturn("AuthorAndChineseTeam-InviteToJoin-10001")->getContent(), true);
                }
            } else {
                if ($MePermission_edit_add_user["edit_add_user"] == 1 && $MePermission_edit_add_user["edit_edit_user"] == 1) {
                    $returnInfo =  Db::table("author_and_chinese_team")
                        ->where($youState)
                        ->update([
                            "exp_state" => 14
                        ]);
                    if ($returnInfo) {
                        return json_decode(successJsonReturn()->getContent(), true);
                    } else {
                        return json_decode(errorJsonReturn("AuthorAndChineseTeam-InviteToJoin-10002")->getContent(), true);
                    }
                } else {
                    return json_decode(errorJsonReturn("AuthorAndChineseTeam-InviteToJoin-10000")->getContent(), true);
                }
            }
        } else {
            return $postData;
        }
    }

    /**
     * @方法名: 插入数据库并且发送邀请邮件
     * @作者: 初雪桜
     * @信息: 插入数据库并且发送邀请邮件
     * @param Json $user_info 对方的 用户信息
     * @param String $BookId
     * @param Json $operator_user_info 自己的用户信息
     * @param String $aact_id author_and_chinese_team 表中的 _id
     * @return Json
     */
    public function InsertAndSend($user_info, $BookInfo, $operator_user_info, $aact_id)
    {


        $domain = request()->domain(); //域名
        $private_key = randIdStructure(999999999999999);
        $ComicsAddInvitationAact = new ComicsAddInvitationAact($this->app);
        $insertId =  $ComicsAddInvitationAact->Insert(
            $user_info["user_id"], //对方的用户id
            $BookInfo["_id"], //书籍id
            date("Y-m-d"), //年月日
            $private_key, //私钥
            $operator_user_info['_id'], //自己的id
            null,
            $aact_id
        );
        if ($insertId["code"] == 200) {
            $insertId = $insertId['data'];
        } else {
            return json_decode(errorJsonReturn()->getContent(), true);
        }
        $parameter = json_encode([
            "user_id" => $user_info["user_id"],
            "book_id" => $BookInfo["_id"],
            "Y-m-d" => date("Y-m-d"),
            "id" => $insertId,
        ]);
        $authcodeInfo =  rtrim(strtr(base64_encode(authcode($parameter, 'Encode', $private_key)), '+/', '-_'), '=');
        //首先把生成的加密数据使用私钥加密一下,再把数据 在使用私钥在加密一次 最后获取 base64
        $url =  $domain . "/useradmin/ActivateUser/AuthorAndChineseTeam/$authcodeInfo/$private_key";
        $mailHtml = <<<ect
        <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <tbody>
        <tr>
            <td>
                <table border="0" cellspacing="0" cellpadding="0" align="center" class="subscribe-body" style="width: 100%; padding: 10px">
                    <tbody>
                        <tr>
                            <td>
                                <div style="direction: ltr; max-width: 600px; margin: 0 auto; overflow: hidden;">
                                    <table border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff" class="subscribe-wrapper" style="width: 100%; background-color: #fff; text-align: left; max-width: 1024px; min-width: 320px; margin: 0 auto;">
                                        <tbody>
                                            <tr>
                                                <td>
                                                    <table border="0" cellspacing="0" cellpadding="0" height="8" background="" class="subscribe-header-wrap" style="width: 100%; background-image: url(); background-repeat: repeat-x; background-color: #43A4D0; height: 8px;">
                                                        <tbody>
                                                            <tr>
                                                                <td></td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <table border="0" cellspacing="0" cellpadding="0" class="subscribe-header" style="width: 100%; color: #08c; font-size: 1.6em; background-color: #EFEFEF; border-bottom: 1px solid #DDD; margin: 0; padding: 0;">
                                                        <tbody>
                                                            <tr>
                                                                <td>
                                                                    <h2 class="subscribe-title" style="margin: .4em 0 .3em; font-size: 1.8em; font-size: 16px!important; line-height: 1; font-weight: 400; color: #464646; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; margin: 5px 20px!important; padding: 0;">
                                                                        Welcome to join us <strong>欢迎成为漫画创作者/协作者</strong> </h2>
                                                                </td>
                                                                <td style="text-align: right;">
                                                                    <img border="0" class="head-avatar" src="javascript:;" width="32" height="32" style="vertical-align: middle; margin: 5px 20px 5px 0; vertical-align: middle;">
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <table style="width: 100%" border="0" cellspacing="0" cellpadding="20" bgcolor="#ffffff">
                                                        <tbody>
                                                            <tr>
                                                                <td>
                                                                    <table style="width: 100%" border="0" cellspacing="0" cellpadding="0">
                                                                        <tbody>
                                                                            <tr>
                                                                                <td valign="top" class="the-post">
                                                                                    <table style="width: 100%" border="0" cellspacing="0" cellpadding="0">
                                                                                        <tbody>
                                                                                            <tr>
                                                                                                <td style="width: 60px !important; white-space: nowrap; vertical-align: top;">
                                                                                                    <a href="https://baidu.com" style="color: #2585B2; display: block; margin-right: 10px;" rel="noopener" target="_blank"><img border="0" src="{$operator_user_info['head_images']}" class="avatar avatar-50" height="50" width="50"></a>
                                                                                                </td>
                                                                                                <td>
                                                                                                    <h2 class="post-title" style="margin: .4em 0 .3em; font-size: 1.8em; font-size: 1.6em; color: #555; margin: 0; font-size: 20px;">
                                                                                                        <a href="https://baidu.com" style="color: #2585B2; text-decoration: none;" rel="noopener" target="_blank">
                                                                                                            {$operator_user_info["name"]}
                                                                                                        </a>
                                                                                                    </h2>
                                                                                                    <span style="color: #888;">by
                                                                                                        <a href="https://baidu.com"
                                                                                                            style="color: #2585B2; color: #888 !important;"
                                                                                                            rel="noopener"
                                                                                                            target="_blank">{$BookInfo["title"]} 的创作者</a>
                                                                                                    </span>
                                                                                                </td>
                                                                                            </tr>
                                                                                        </tbody>
                                                                                    </table>
                                                                                    <div class="post-content" style="direction: ltr; margin-top: 1em; max-width: 560px;">
                                                                                        <p style="direction: ltr; font-size: 14px; line-height: 1.4em; color: #444; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; margin: 0 0 1em;">
                                                                                            <img border="0" style="max-width: 100%; height: auto; margin-bottom: 12px;" src="javascript:;"><br><strong><span
                                                                                                    style="color: #ff0000;">尊敬的用户，您好</span></strong> 欢迎您加入<a style="color: #2585B2;" class="more-link" href="{$url}" rel="noopener"
                                                                                                target="_blank"><span
                                                                                                            class="screen-reader-text">"{$BookInfo["title"]}"</span>
                                                                                                            </a>此漫画创作团队
                                                                                            <br>这本漫画作者诚邀您的加入
                                                                                        </p>
                                                                                        <div style="direction: ltr; clear: both">
                                                                                        </div>
                                                                                    </div>

                                                                                    <p class="subscribe-action-links" style="direction: ltr; font-size: 14px; line-height: 1.4em; color: #444; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; margin: 0 0 1em; font-size: 14px; color: #666; padding: 0; width: auto; padding-top: 1em; padding-bottom: 0em; margin-bottom: 0; margin-left: 0; padding-left: 0;">
                                                                                    </p>
                                                                                    <table class="auto-width" border="0" cellspacing="0" cellpadding="0" style="width: 100%; width: auto">
                                                                                        <tbody>
                                                                                            <tr>
                                                                                                <td style="width: 10px;">
                                                                                                    <a href="$url" style="color: #2585B2; -moz-border-radius: 10em; -webkit-border-radius: 10em; border-radius: 10em; border: 1px solid #11729E; text-decoration: none; color: #fff; text-shadow: 0 1px 0 #11729E; background-color: #2585B2; padding: 5px 15px; font-size: 16px; line-height: 1.4em; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-weight: normal; margin-left: 0; white-space: nowrap;"
                                                                                                        rel="noopener" target="_blank">加入</a>
                                                                                                </td>
                                                                                                <td>&nbsp;&nbsp;&nbsp;<a style="color: #2585B2;" class="subscribe-action-link" href="$url" rel="noopener" target="_blank">
                                                                                                        拒绝</a>
                                                                                                </td>
                                                                                            </tr>
                                                                                        </tbody>
                                                                                    </table>
                                                                                </td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <table border="0" cellspacing="0" cellpadding="20" bgcolor="#efefef" class="subscribe-wrapper-sub" style="width: 100%; background-color: #efefef; text-align: left; border-top: 1px solid #ddd;">
                                                        <tbody>
                                                            <tr>
                                                                <td class="subscribe-content" style="border-top: 1px solid #f3f3f3; color: #888; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; background: #efefef;">
                                                                    <p style="direction: ltr; font-size: 14px; line-height: 1.4em; color: #444; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; margin: 0 0 1em; font-size: 12px; line-height: 1.4em; margin: 0px 0px 10px 0px;">
                                                                        <a style="color: #2585B2;" rel="noopener" target="_blank">提示</a> 这是一封自动发送的邮件<br> 如果想不再接收拒收 <a style="color: #2585B2;" href="\$url2" rel="noopener" target="_blank">点我设置</a>.
                                                                    </p>

                                                                    <p style="direction: ltr; font-size: 14px; line-height: 1.4em; color: #444; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; margin: 0 0 1em; font-size: 12px; line-height: 1.4em; margin: 0px 0px 0px 0px;">
                                                                        <strong>无法点击吗</strong> 复制下面连接到浏览器: <a style="color: #2585B2;" href="$url" rel="noopener" target="_blank">$url</a>
                                                                    </p>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <table border="0" cellspacing="0" cellpadding="0" height="3" background="" class="subscribe-footer-wrap" style="width: 100%; background-image: url(); background-repeat: repeat-x; background-color: #43A4D0; height: 3px;">
                                        <tbody>
                                            <tr>
                                                <td></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table><br>
            </td>
        </tr>
    </tbody>
</body>

</html>
ect;


        return sendMail("sakura_223@icloud.com", '邀请您加入《xxx》漫画', $mailHtml, [
            /*  [
                "fileSrc" => "https://i0.hdslb.com/bfs/album/619fe3ebc7c8c1f0dcd9494c8c5d2d4b29e60a85.jpg",
                "fileName" => 'aaa.jpej',
            ] */]);
    }
}
